package com.foreveross.mofang.datapersistence.application.impl;

import org.dayatang.domain.InstanceFactory;
import org.dayatang.ioc.spring.factory.SpringInstanceProvider;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * 所有单元集成测试的基类，用于一些注解配制与初始化操作
 * 
 * @author fb
 */
 
 
@RunWith(SpringJUnit4ClassRunner.class) 
@Transactional(propagation = Propagation.REQUIRED)
@ContextConfiguration(locations = { "classpath*:META-INF/spring/root.xml" })
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
public abstract class BaseJunit extends AbstractTransactionalJUnit4SpringContextTests {
	Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Before
	public void setUp() throws Exception {
		logger.debug("applicationContext: " + applicationContext);
		InstanceFactory.setInstanceProvider(new SpringInstanceProvider(
				applicationContext));
	}
}
